package com.meritit.springcloud;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.sleuth.sampler.AlwaysSampler;
import org.springframework.context.annotation.Bean;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

@SpringBootApplication
@RestController
public class SpringZipkinClientApplication {

	@Bean
	public RestTemplate createTemplate() {
		return new RestTemplate();
	}
	
	@Bean
	public AlwaysSampler alwaysSampler() {
		return new AlwaysSampler();
	}
	
	@Autowired
	private RestTemplate restTemplate;
	
	@RequestMapping("/hi")
	public String hi() {
		return restTemplate.getForObject("http://localhost:9102/miya", String.class);
	}
	
	@RequestMapping("/info")
	public String info() {
		return "I'm zipkin client 9101";
	}
	
	public static void main(String[] args) {
		SpringApplication.run(SpringZipkinClientApplication.class, args);
	}
}
